package link.dzl.pusher.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
public class MsgSender {

    /**
     * 使用RabbitTemplate, 提供了接收/发送等等方法
     */
    @Resource
    RabbitTemplate rabbitTemplate;

    @GetMapping("/send/{msg}")
    public String sendDirectMessage(@PathVariable(name = "msg") String msg) {

        // 将消息携带绑定键值: TestDirectRouting 发送到交换机TestDirectExchange
        rabbitTemplate.convertAndSend("directExchange", "directRouting", msg);
        return "ok";
    }

}